import requests

url= 'https://www.baidu.com/s'

headers={
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0'
}
kw={
    'wd':'python'
}
#添加查询字符串
response = requests.get(url,params=kw,headers=headers)
#获取状态码
print(response.status_code)
#获取服务器返回的字节数据
print(response.content)
#获取服务器返回的字符串数据
print(response.text)
#通过返回的字节数据转换为字符串
print(response.content.decode('utf-8'))
#获取请求头
print(response.request.headers)
#获取响应头
print(response.headers)
#获取请求中携带的cookie信息
print(response.request.headers.get('Cookie'))
#获取响应中携带的set-cookie信息，返回对象的类型RequsetsCookiteJar通过dict转为字典
print(dict(response.cookies))
# 获取请求域名
print(response.url)